﻿using System;
using System.ComponentModel;
using System.Windows;

namespace Elentok.Common.Wpf.Dialogs
{
  ///// <summary>
  ///// Base implementation of a dialog
  ///// </summary>
  //public class DialogBase<T> : Window
  //  where T : IDialogViewModel
  //{
  //  private bool userPressedCloseButton = false;

  //  #region Ctor

  //  /// <summary>
  //  /// Initializes a new instance of the <see cref="DialogBase&lt;T&gt;"/> class
  //  /// </summary>
  //  /// <param name="viewModel"></param>
  //  public DialogBase(T viewModel)
  //  {
  //    this.DataContext = viewModel;
  //    viewModel.Closed += new EventHandler(ViewModel_Closed);
  //  } 

  //  #endregion

  //  private void ViewModel_Closed(object sender, EventArgs e)
  //  {
  //    // if the user pressed the close button, then we're already within
  //    // the OnClosing method and we don't need to call "Close" again
  //    if (userPressedCloseButton)
  //      return;

  //    Close();
  //  }

  //  /// <summary>
  //  /// Gets the view model associated with this dialog
  //  /// </summary>
  //  public T ViewModel
  //  {
  //    get { return (T)this.DataContext; }
  //  }

  //  /// <summary>
  //  /// This method is called when the "Close" method is called
  //  /// or when the user clicks the window's "Close" button.
  //  /// </summary>
  //  /// <param name="e"></param>
  //  protected override void OnClosing(CancelEventArgs e)
  //  {
  //    // if the view model isn't closed, it means the closing
  //    // was triggered by the window's close button, so we
  //    // need to execute the view model's Cancel command
  //    if (!this.ViewModel.IsClosed)
  //    {
  //      this.userPressedCloseButton = true;

  //      if (this.ViewModel.CancelCommand != null)
  //        this.ViewModel.CancelCommand.Execute(null);
  //    }

  //    // if the view model is still not closed, abort the close
  //    if (!this.ViewModel.IsClosed)
  //    {
  //      this.userPressedCloseButton = false;
  //      e.Cancel = true;
  //    }

  //    base.OnClosing(e);
  //  }

  //  protected override void OnContentRendered(EventArgs e)
  //  {
  //    base.OnContentRendered(e);

  //    this.ViewModel.OnShown();
  //  }

  //}
}
